
<?php 
	include_once("header.php");
?>

 <style type="text/css">
 body{background: #f2f2ef;}
 .gain_box{width: 284px;height: 42px;margin: auto;margin-top: 15px;  overflow: hidden;}
 .phone_box , .code_box{height: 40px;border: 1px solid #e3e3e1;background-color: #fff;border-radius: 5px;-webkit-border-radius: 5px;-moz-border-radius: 5px;overflow: hidden;}
 .phone_box{width: 195px;float: left;}
 .inp_phone,.inp_code{height: 20px;line-height: 20px;font-size:16px;margin-top: 10px;color: #2a2a2a;}
			.inp_phone{width: 190px;}
			.inp_code{width: 283px;}
			.gain_code{width: 77px;display: block;background: #ff7430;float: right;font-size: 14px;}
			.un{background-color:#e0e0e0;}
			.tit{width: 284px;height: 30px;line-height:30px;font-size: 12px;text-align: left;margin: 0 auto;color: #878787;}
			.tit em{color: #ff7430;}
			.code_box{width: 284px;margin: 0 auto;margin-top:10px;}
			.login{width: 284px;margin: 0 auto;background: #ff7430;font-size: 17px;margin-top: 11px;}
			select, input {
			  vertical-align: middle;
			}
			input, textarea {
			  border: 0;
			  outline: 0;
			  text-indent: 10px;
			  -webkit-appearance: none;
			  margin: 0;
			  padding: 0;
			}
			.btn {
  height: 40px;
  color: #fff;
  line-height: 40px;
  border-radius: 5px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  text-align: center;
}
 </style>

 <!-- top_bar -->
 <div class="gain_box">
	 <div class="phone_box">
		 <input type="tel" placeholder="请输入手机号" maxlength="11" class="inp_phone"/>
	 </div>
     <span class="btn gain_code">获取验证码</span>
 </div>


<div class="code_box">
     <input type="tel" placeholder="输入验证码" class="inp_code"/>
</div>

<div class="btn login">立即登录</div>

<div class="tit ty_tit">点击“立即登录” -即表示您同意<em class="plxy">《用户协议》</em></div>
 
 
<script type="text/javascript">
			var wait=60;
		    function time(o) {
		        if (wait == 0) {
		        	$(o).removeClass('un');  
		            $(o).text("重新获取");
		            wait = 60;
		            $('.yy_tit').show();
		            $('.code_box').css("margin-top",0);
		        }else if(wait == 30){
		        	//$('.yy_tit').show();
		            //$('.code_box').css("margin-top",0);
		            $(o).text(wait+"秒");
		            wait--;
		            setTimeout(function() {
		                time(o)
		            },
		            1000);
		        } else {
		        	$(o).addClass('un');
		            $(o).text(wait+"秒");
		            wait--;
		            setTimeout(function() {
		                time(o)
		            },
		            1000);
		        }
		    }

			$('document').ready(function(){

				//查看协议
				$('.ty_tit .plxy').click(function(){
					//$.load_page({url:"http://peilian.test.58v5.cn/more/protocol",title:"陪练协议"});
				});
				
				//发送验证码
				$('.gain_code , .yy_tit em').bind('click',function(){
					var type = $(this).attr('type');
					if ((type != "call" && wait == 60) || type == "call") {
 
						var phone = $('.inp_phone').val();

						if(phone==''){
		                      layer.open({
								    content: '请填写完整',
								    className: 'bluelayer',
								    time: 2
								});
						    return false;
						} 

						var thisvar = this;
 
				        $.ajax({
				            url: '/index.php/profile/getsmscode',
				            type: 'POST',
				            data:{phonenumber:phone},
				            dataType: 'json',
				            error: function(){
				                  alert('Error '); 
				                  posting = false;
				                 },
				            success: function(result){
 
				                if(result.result==1){
				                	layer.open({
									    content: '获取成功，请保持手机畅通！',
									    className: 'bluelayer',
									    time: 2
									});

			 					// 	var value = {phone:$('.phone_box input').val(),source:2 };
									// if(type == "call"){
									// 	value.call = "1";
									// }else{
									// 	time(this);
									// }
									time(thisvar);

				                }else{
				                	layer.open({
									    content: '请填写正确的手机号',
									    className: 'bluelayer',
									    time: 2
									});

				                } 

				            }

				        });

 
  
						// $.post(rooturl + "/order/getcode", value, function(resp){
						// 	if("false"==(resp.toString())){
					 //            $.common.toast("获取验证码失败!");
					 //  		}else{
					 //            $.common.toast("获取成功,请保持手机畅通!" , 2000);
					 //  		}
						// }); s
					}else{
						//$.common.toast('请在'+wait+'秒后重新获取');
					};
				});
				
			  	//登录
 				$('.login').bind("click", function(){
					var phone = $('.inp_phone').val();
					var code = $('.inp_code').val();

					if(phone == "" || phone == undefined){
						//$.common.toast("请输入电话号码!");
						return;
					}

 					if(code == "" || code == undefined){
				                	layer.open({
									    content: '请填写验证码',
									    className: 'bluelayer',
									    time: 2
									});
						return;
					}

 				//var backurl = encodeURI("http://www.xunlianri.com/index.php/profile/wxreg");
 				var from = "<?=$from?>";
			    var redirect_uri = encodeURI("http://www.xunlianri.com/wxoauth2/authcoach.php?from"+from);
			    var oauth2_uri = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8ed1756092833c6a&redirect_uri="+redirect_uri+"&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
			    location.href=oauth2_uri; 


				});
			});
</script>

<?php 
	include_once("footer.php");
?>


